package com.hspedu.customgeneric;

import java.util.Arrays;

/**
 * @author LiuJinTao
 * @className CustomerGeneric
 * @date 2024/06/16 12:22
 * @description TODO
 */
public class CustomGeneric {
    public static void main(String[] args) {

    }
}

class Tiger<T, R, M> {
    String name;
    R r;
    T t;
    M m;
    // 因为数据在初始化的时候不能确定 T 的类型，就无法在内存开空间
//    T[] ts = new T[8];
    T[] ts;

    @Override
    public String toString() {
        return "Tiger{" +
                "name='" + name + '\'' +
                ", r=" + r +
                ", t=" + t +
                ", m=" + m +
                ", ts=" + Arrays.toString(ts) +
                '}';
    }

    public Tiger(String name) {
        this.name = name;
    }

    public Tiger(R r, T t, M m) {
        this.r = r;
        this.t = t;
        this.m = m;
    }

    public Tiger(String name, R r, T t, M m) {
        this.name = name;
        this.r = r;
        this.t = t;
        this.m = m;
    }

    // 静态和对象无关，与类有关，在加载类的时候就会加载 static 此时 M 类型无法确定
//    public static void m1(M m) {}

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public R getR() {
        return r;
    }

    public void setR(R r) {
        this.r = r;
    }

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }

    public M getM() {
        return m;
    }

    public void setM(M m) {
        this.m = m;
    }
}